﻿namespace GameSchool.Models.ExamModels
{
    public class ExamQuestionModel
    {
        public ExamQuestionModel()
        {
        }

        public ExamQuestionModel(ExamQuestion examQuestion)
        {
            ExamQuestion = examQuestion.Question;
            ExamQuestionNo = examQuestion.ExamQuestionID;

            int counter = 1;
            foreach (var eqa in examQuestion.ExamQuestionAnswers)
            {
                switch (counter)
                {
                    case 1:
                        {
                            ExamQuestionAnswer1 = eqa.Answer;
                            ExamQuestionAnswerId1 = eqa.ExamQuestionAnswerID;
                            counter++;
                            if (eqa.IsCorrect)
                            {
                                CorrectAnswerIsNo = 1;
                                CorrectAnswerId = eqa.ExamQuestionAnswerID;
                            }
                            break;
                        }
                    case 2:
                        {
                            ExamQuestionAnswer2 = eqa.Answer;
                            ExamQuestionAnswerId2 = eqa.ExamQuestionAnswerID;
                            counter++;
                            if (eqa.IsCorrect)
                            {
                                CorrectAnswerIsNo = 2;
                                CorrectAnswerId = eqa.ExamQuestionAnswerID;
                            }
                            break;
                        }
                    case 3:
                        {
                            ExamQuestionAnswer3 = eqa.Answer;
                            ExamQuestionAnswerId3 = eqa.ExamQuestionAnswerID;
                            counter++;
                            if (eqa.IsCorrect)
                            {
                                CorrectAnswerIsNo = 3;
                                CorrectAnswerId = eqa.ExamQuestionAnswerID;
                            }
                            break;
                        }
                    case 4:
                        {
                            ExamQuestionAnswer4 = eqa.Answer;
                            ExamQuestionAnswerId4 = eqa.ExamQuestionAnswerID;
                            counter++;
                            if (eqa.IsCorrect)
                            {
                                CorrectAnswerIsNo = 4;
                                CorrectAnswerId = eqa.ExamQuestionAnswerID;
                            }
                            break;
                        }
                }
            }
        }

        public int ExamQuestionNo { get; set; }
        public string ExamQuestion { get; set; }
        public int ExamQuestionAnswerId1 { get; set; }
        public string ExamQuestionAnswer1 { get; set; }
        public int ExamQuestionAnswerId2 { get; set; }
        public string ExamQuestionAnswer2 { get; set; }
        public int ExamQuestionAnswerId3 { get; set; }
        public string ExamQuestionAnswer3 { get; set; }
        public int ExamQuestionAnswerId4 { get; set; }
        public string ExamQuestionAnswer4 { get; set; }
        public int CorrectAnswerIsNo { get; set; }
        public int CorrectAnswerId { get; set; }
        public int AnsweredId { get; set; }
    }
}